//
//  University.m
//  DIsciplineSelectPartner
//
//  Created by 唐秦崴 on 15/3/13.
//  Copyright (c) 2015年 Lizzy. All rights reserved.
//

#import "University.h"

@implementation University

@synthesize  objectId = _objectId;   // objectId
@synthesize  name = _name;     // 名称
@synthesize  order = _order;    // 本省排名
@synthesize  province = _province;    // 省份
@synthesize  universityDescription = _universityDescription; // 大学简介
@synthesize  unit = _unit; // 招生单元
@synthesize  picString = _picString; // 图片url

- (instancetype)initWithBmobObject : (BmobObject*) bmobObject
{
    self = [super init];
    
    if (bmobObject) {
        self.objectId   = bmobObject.objectId;
        self.name       = [bmobObject objectForKey:@"name"];
        self.order      = (int)[bmobObject objectForKey:@"order"];
        self.province   = [bmobObject objectForKey:@"province"];
        self.universityDescription = [bmobObject objectForKey:@"description"];
        self.unit       = [bmobObject objectForKey:@"unit"];
        self.picString  = [bmobObject objectForKey:@"pic"];
    }
    
    return self;
    
}

- (instancetype)initWithUniversity : (University*) university
{
    self = [super init];
    
    if (university) {
        self.objectId   = university.objectId;
        self.name       = university.name;
        self.order      = university.order;
        self.province   = university.province;
        self.universityDescription = university.universityDescription;
        self.unit       = university.unit;
        self.picString  = university.picString;
    }
    
    return self;
    
}


- (instancetype)initWithOnlyName : (NSString*) name
{
    self = [super init];
    if (name) {
        self.name = name;
    }
    return self;
}

// 获取大学的图片URL
-(NSString*) picURL
{
    if ( self.picString ) {
        NSArray *strArray = [self.picString componentsSeparatedByString:@"\""];
        return [ strArray objectAtIndex:1 ];
    }else{
        return nil;
    }
    
}

@end